# from docx import Document
# import os
# doc = Document()
# target_size = 10 * 1024 * 1024  # 10M in bytes
# while os.path.getsize(doc.name) < (target_size if os.path.exists(doc.name) else 0) :
#         doc.add_paragraph("这是一个用于填充文档的示例段落。这是一个用于填充文档的示例段落。这是一个用于填充文档的示例段落。")
# file_path = "big_document.docx"
# doc.save(file_path)



from docx import Document
import string
import os
import random


path = os.path.abspath(__file__)
print(path)

fname = path.replace("doc.py", "large_document.docx")
print(fname)
# 快速生成一个 10MB 的 Word 文档
def generate_big_word_doc(target_size):
    doc = Document()
    i = 1
    while i < target_size:
        doc.add_paragraph("".join(random.choice(string.ascii_letters) for _ in range(100)))

        i = i + 1
        print(i)

    doc.save(r'C:\Users\zhou\Desktop\ruoyi2\ruoyi-ui\large_document.docx')

generate_big_word_doc( 10 * 1024 * 1024)
